cmake_minimum_required(VERSION 2.6)

set( LIB_NAME minizip )
project(minizip)

set( HEADER_FILES
    crypt.h
    ioapi.h
    iowin32.h
    mztools.h
    unzip.h
    zip.h
)

set( CMAKE_INCLUDE_PATH $ENV{ZLIB_DIR}/include )
set( CMAKE_LIBRARY_PATH $ENV{ZLIB_DIR}/lib )
find_package( ZLIB )

include_directories( ${ZLIB_INCLUDE_DIRS} )

add_library( minizip minizip.c zip.c ioapi.c  ${HEADER_FILES})
add_library( miniunz miniunz.c unzip.c ioapi.c iowin32.c ${HEADER_FILES})
add_executable( miniunzexe miniunz.c unzip.c ioapi.c iowin32.c ${HEADER_FILES})

#set_target_properties( ${LIB_NAME} PROPERTIES COMPILE_DEFINITIONS "_LIB;_OPEN_BINARY;HAVE_IO_H;HAVE_FCNTL_H;HAVE_STDARG_H;HAVE_BASETSD_H;HAVE_SYS_TYPES_H" )
set_target_properties( minizip PROPERTIES DEBUG_POSTFIX "-d" )
set_target_properties( miniunz PROPERTIES DEBUG_POSTFIX "-d" )
set_target_properties( miniunzexe PROPERTIES DEBUG_POSTFIX "-d" )

target_link_libraries( minizip ${ZLIB_LIBRARIES} )
target_link_libraries( miniunz ${ZLIB_LIBRARIES} )
target_link_libraries( miniunzexe ${ZLIB_LIBRARIES} )

#install
install( FILES ${HEADER_FILES} DESTINATION include COMPONENT minizip-dev)
install( TARGETS minizip miniunz miniunzexe RUNTIME DESTINATION bin ARCHIVE DESTINATION lib COMPONENT minizip-dev)
